using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._SpatialStatisticsTools._ModelingSpatialRelationships
{
    /// <summary>
    /// <para>Local Bivariate Relationships</para>
    /// <para>Analyzes two variables for statistically significant relationships using local entropy. Each feature is classified into one of six categories based on the type of relationship. The output can be used to visualize areas where the variables are related and explore how their relationship changes across the study area.</para>
    /// <para>使用局部熵分析两个变量的统计显著性关系。根据关系类型，每个要素都分为六个类别之一。输出可用于可视化变量相关的区域，并探索它们之间的关系在整个研究区域中的变化情况。</para>
    /// </summary>    
    [DisplayName("Local Bivariate Relationships")]
    public class LocalBivariateRelationships : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public LocalBivariateRelationships()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_features">
        /// <para>Input Features</para>
        /// <para>The feature class containing fields representing the Dependent Variable and Explanatory Variable values.</para>
        /// <para>包含表示因变量和解释变量值的字段的要素类。</para>
        /// </param>
        /// <param name="_dependent_variable">
        /// <para>Dependent Variable</para>
        /// <para>The numeric field representing the values of the dependent variable. When categorizing the relationships, the Explanatory Variable value is used to predict the Dependent Variable value.</para>
        /// <para>表示因变量值的数值字段。对关系进行分类时，“解释变量”值用于预测“因变量”值。</para>
        /// </param>
        /// <param name="_explanatory_variable">
        /// <para>Explanatory Variable</para>
        /// <para>The numeric field representing the values of the explanatory variable. When categorizing the relationships, the Explanatory Variable value is used to predict the Dependent Variable value.</para>
        /// <para>表示解释变量值的数值字段。对关系进行分类时，“解释变量”值用于预测“因变量”值。</para>
        /// </param>
        /// <param name="_output_features">
        /// <para>Output Features</para>
        /// <para>The output feature class containing all input features with fields representing the Dependent Variable value, Explanatory Variable value, entropy score, pseudo p-value, level of significance, type of categorized relationship, and diagnostics related to the categorization.</para>
        /// <para>包含所有输入要素的输出要素类，其字段表示因变量值、解释变量值、熵分数、伪 p 值、显著性级别、分类关系类型以及与分类相关的诊断。</para>
        /// </param>
        public LocalBivariateRelationships(object _in_features, object _dependent_variable, object _explanatory_variable, object _output_features)
        {
            this._in_features = _in_features;
            this._dependent_variable = _dependent_variable;
            this._explanatory_variable = _explanatory_variable;
            this._output_features = _output_features;
        }
        public override string ToolboxName => "Spatial Statistics Tools";

        public override string ToolName => "Local Bivariate Relationships";

        public override string CallName => "stats.LocalBivariateRelationships";

        public override List<string> AcceptEnvironments => ["outputCoordinateSystem", "parallelProcessingFactor", "randomGenerator"];

        public override object[] ParameterInfo => [_in_features, _dependent_variable, _explanatory_variable, _output_features, _number_of_neighbors, _number_of_permutations, _enable_local_scatterplot_popups.GetGPValue(), _level_of_confidence.GetGPValue(), _apply_false_discovery_rate_fdr_correction.GetGPValue(), _scaling_factor];

        /// <summary>
        /// <para>Input Features</para>
        /// <para>The feature class containing fields representing the Dependent Variable and Explanatory Variable values.</para>
        /// <para>包含表示因变量和解释变量值的字段的要素类。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_features { get; set; }


        /// <summary>
        /// <para>Dependent Variable</para>
        /// <para>The numeric field representing the values of the dependent variable. When categorizing the relationships, the Explanatory Variable value is used to predict the Dependent Variable value.</para>
        /// <para>表示因变量值的数值字段。对关系进行分类时，“解释变量”值用于预测“因变量”值。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Dependent Variable")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _dependent_variable { get; set; }


        /// <summary>
        /// <para>Explanatory Variable</para>
        /// <para>The numeric field representing the values of the explanatory variable. When categorizing the relationships, the Explanatory Variable value is used to predict the Dependent Variable value.</para>
        /// <para>表示解释变量值的数值字段。对关系进行分类时，“解释变量”值用于预测“因变量”值。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Explanatory Variable")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _explanatory_variable { get; set; }


        /// <summary>
        /// <para>Output Features</para>
        /// <para>The output feature class containing all input features with fields representing the Dependent Variable value, Explanatory Variable value, entropy score, pseudo p-value, level of significance, type of categorized relationship, and diagnostics related to the categorization.</para>
        /// <para>包含所有输入要素的输出要素类，其字段表示因变量值、解释变量值、熵分数、伪 p 值、显著性级别、分类关系类型以及与分类相关的诊断。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _output_features { get; set; }


        /// <summary>
        /// <para>Number of Neighbors</para>
        /// <para>The number of neighbors around each feature (including the feature) that will be used to test for a local relationship between the variables. The number of neighbors must be between 30 and 1000, and the default is 30. The provided value should be large enough to detect the relationship between features, but small enough to still identify local patterns.</para>
        /// <para>每个要素（包括要素）周围的邻居数，这些邻居将用于检验变量之间的局部关系。邻居的数量必须介于 30 到 1000 之间，默认值为 30。提供的值应足够大，以检测特征之间的关系，但又应足够小，以便仍能识别局部模式。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Number of Neighbors")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long _number_of_neighbors { get; set; } = 30;


        /// <summary>
        /// <para>Number of Permutations</para>
        /// <para><xdoc>
        ///   <para>Specifies the number of permutations used to calculate the pseudo p-value for each feature. Choosing a number of permutations is a balance between precision in the pseudo p-value and increased processing time.</para>
        ///   <bulletList>
        ///     <bullet_item>99 permutations—With 99 permutations, the smallest possible pseudo p-value is 0.01, and all other pseudo p-values will be multiples of this value.</bullet_item><para/>
        ///     <bullet_item>199 permutations—With 199 permutations, the smallest possible pseudo p-value is 0.005, and all other pseudo p-values will be multiples of this value. This is the default.</bullet_item><para/>
        ///     <bullet_item>499 permutations—With 499 permutations, the smallest possible pseudo p-value is 0.002, and all other pseudo p-values will be multiples of this value.</bullet_item><para/>
        ///     <bullet_item>999 permutations—With 999 permutations, the smallest possible pseudo p-value is 0.001, and all other pseudo p-values will be multiples of this value.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定用于计算每个要素的伪 p 值的排列数。选择多个排列是在伪 p 值的精度和增加的处理时间之间取得平衡。</para>
        ///   <bulletList>
        ///     <bullet_item>99 种排列—使用 99 种置换时，可能的最小伪 p 值为 0.01，所有其他伪 p 值都将是此值的倍数。</bullet_item><para/>
        ///     <bullet_item>199 个置换—如果有 199 个置换，可能的最小伪 p 值为 0.005，所有其他伪 p 值都将是该值的倍数。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>499 个排列—对于 499 个置换，可能的最小伪 p 值为 0.002，所有其他伪 p 值都将是此值的倍数。</bullet_item><para/>
        ///     <bullet_item>999 排列—对于 999 个排列，可能的最小伪 p 值为 0.001，所有其他伪 p 值都将是此值的倍数。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Number of Permutations")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long _number_of_permutations { get; set; } = 199;


        /// <summary>
        /// <para>Enable Local Scatterplot Pop-ups</para>
        /// <para><xdoc>
        ///   <para>Specifies whether scatterplot pop-ups will be generated for each output feature. Each scatterplot displays the values of the explanatory (horizontal axis) and dependent (vertical axis) variables in the local neighborhood along with a fitted line or curve visualizing the form of the relationship. Scatterplot charts are not supported for shapefile outputs.</para>
        ///   <bulletList>
        ///     <bullet_item>Checked—Local scatterplot pop-ups will be generated for each feature in the dataset. This is the default.</bullet_item><para/>
        ///     <bullet_item>Unchecked—Local scatterplot pop-ups will not be generated.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定是否为每个输出要素生成散点图弹出窗口。每个散点图显示局部邻域中解释变量（水平轴）和因变量（垂直轴）变量的值，以及可视化关系形式的拟合线或曲线。shapefile 输出不支持散点图。</para>
        ///   <bulletList>
        ///     <bullet_item>选中—将为数据集中的每个要素生成局部散点图弹出窗口。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>未选中—不会生成局部散点图弹出窗口。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Enable Local Scatterplot Pop-ups")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _enable_local_scatterplot_popups_value _enable_local_scatterplot_popups { get; set; } = _enable_local_scatterplot_popups_value._true;

        public enum _enable_local_scatterplot_popups_value
        {
            /// <summary>
            /// <para>CREATE_POPUP</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("CREATE_POPUP")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NO_POPUP</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_POPUP")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Level of Confidence</para>
        /// <para><xdoc>
        ///   <para>Specifies a confidence level of the hypothesis test for significant relationships.</para>
        ///   <bulletList>
        ///     <bullet_item>90%—The confidence level is 90 percent. This is the default.</bullet_item><para/>
        ///     <bullet_item>95%—The confidence level is 95 percent.</bullet_item><para/>
        ///     <bullet_item>99%—The confidence level is 99 percent..</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定显著关系的假设检验的置信度。</para>
        ///   <bulletList>
        ///     <bullet_item>90% - 置信水平为 90%。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>95%—置信水平为 95%。</bullet_item><para/>
        ///     <bullet_item>99%—置信度为 99%。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Level of Confidence")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _level_of_confidence_value _level_of_confidence { get; set; } = _level_of_confidence_value.value0;

        public enum _level_of_confidence_value
        {
            /// <summary>
            /// <para>90%</para>
            /// <para>90%—The confidence level is 90 percent. This is the default.</para>
            /// <para>90% - 置信水平为 90%。这是默认设置。</para>
            /// </summary>
            [Description("90%")]
            [GPEnumValue("90%")]
            value0,

            /// <summary>
            /// <para>95%</para>
            /// <para>95%—The confidence level is 95 percent.</para>
            /// <para>95%—置信水平为 95%。</para>
            /// </summary>
            [Description("95%")]
            [GPEnumValue("95%")]
            value1,

            /// <summary>
            /// <para>99%</para>
            /// <para>99%—The confidence level is 99 percent..</para>
            /// <para>99%—置信度为 99%。</para>
            /// </summary>
            [Description("99%")]
            [GPEnumValue("99%")]
            value2,

        }

        /// <summary>
        /// <para>Apply False Discovery Rate (FDR) Correction</para>
        /// <para><xdoc>
        ///   <para>Specifies whether False Discover Rate (FDR) correction will be applied to the pseudo p-values.</para>
        ///   <bulletList>
        ///     <bullet_item>Checked—Statistical significance will be based on the FDR correction. This is the default.</bullet_item><para/>
        ///     <bullet_item>Unchecked—Statistical significance will be based on the pseudo p-value.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定是否将错误发现率 （FDR） 校正应用于伪 p 值。</para>
        ///   <bulletList>
        ///     <bullet_item>选中 - 统计显著性将基于 FDR 校正。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>未选中 - 统计显著性将基于伪 p 值。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Apply False Discovery Rate (FDR) Correction")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _apply_false_discovery_rate_fdr_correction_value _apply_false_discovery_rate_fdr_correction { get; set; } = _apply_false_discovery_rate_fdr_correction_value._true;

        public enum _apply_false_discovery_rate_fdr_correction_value
        {
            /// <summary>
            /// <para>APPLY_FDR</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("APPLY_FDR")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NO_FDR</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_FDR")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Scaling Factor (Alpha)</para>
        /// <para>Controls the sensitivity to subtle relationships between the variables. Larger values (closer to one) can detect relatively weak relationships, while smaller values (closer to zero) will only detect strong relationships. Smaller values are also more robust to outliers. The value must be between 0.01 and 1, and the default is 0.5.</para>
        /// <para>控制对变量之间微妙关系的敏感度。较大的值（接近 1）可以检测相对较弱的关系，而较小的值（接近零）只能检测强关系。值越小，对异常值也越可靠。该值必须介于 0.01 和 1 之间，默认值为 0.5。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Scaling Factor (Alpha)")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double _scaling_factor { get; set; } = 0.5;


        public LocalBivariateRelationships SetEnv(object outputCoordinateSystem = null, object parallelProcessingFactor = null, object randomGenerator = null)
        {
            base.SetEnv(outputCoordinateSystem: outputCoordinateSystem, parallelProcessingFactor: parallelProcessingFactor, randomGenerator: randomGenerator);
            return this;
        }

    }

}